/*
 This file is part of Musimage, a project which makes possible listen to music
 and, at the same time, watch pictures related with that music.
 Copyright (C) 2006  David Garcia Narbona 

 Musimage is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 Musimage is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Musimage; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package brokerExt;

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;

// Clase que engloba todo el acceso a los datos de la base de datos
// por parte de los diferentes threads del servidor
public class DataBaseManager extends DataBaseConnection {

	// ** Atributos **////////////////////////////////////////
	static private DataBaseManager dataBaseManager;

	// ///////////////////////////////////////////////////////

	// ** Metodos **//////////////////////////////////////////

	// Constructor
	public DataBaseManager() {

		super();
		dataBaseManager = null;
	}

	// Metodo para obtener la unica instancia existente de esta clase
	public static DataBaseManager getInstance() {

		if (dataBaseManager == null) {

			dataBaseManager = new DataBaseManager();
		}

		return dataBaseManager;
	}

	public String findSong(String songName) {

		try {
			// obtiene una conexion del pool de conexiones
			Connection connection = dataSource.getConnection();

			// crea un objeto Statement sobre la conexion
			Statement statement = connection.createStatement();

			String query = "SELECT * from prueba;";

			ResultSet resultSet = statement.executeQuery(query);

			if (resultSet.next()) {

				// while(resultSet.next())
			}

			// devuelve la conexion al pool de conexiones
			connection.close();
		} catch (Exception e) {
			System.err.println("Error in findRDFFile " + e.getClass()
					+ " said:'" + e.getMessage() + "'\n");
		}

		return null;
	}

	// ////////////////////////////////////////////////////////
}
